home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / intsdkss.lha / include / sys / protosw.h < prev    next >
C/C++ Source or Header  |  1996-04-09  |  8KB  |  206 lines

  1. #ifndef SYS_PROTOSW_H
  2. #define SYS_PROTOSW_H
  3. /*
  4.  * Copyright (c) 1982, 1986 Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms are permitted
  8.  * provided that the above copyright notice and this paragraph are
  9.  * duplicated in all such forms and that any documentation,
  10.  * advertising materials, and other materials related to such
  11.  * distribution and use acknowledge that the software was developed
  12.  * by the University of California, Berkeley.  The name of the
  13.  * University may not be used to endorse or promote products derived
  14.  * from this software without specific prior written permission.
  15.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18.  *
  19.  *    @(#)protosw.h   7.3 (Berkeley) 6/27/88
  20.  */
  21.  
  22. /*
  23.  * Protocol switch table.
  24.  *
  25.  * Each protocol has a handle initializing one of these structures,
  26.  * which is used for protocol-protocol and system-protocol communication.
  27.  *
  28.  * A protocol is called through the pr_init entry before any other.
  29.  * Thereafter it is called every 200ms through the pr_fasttimo entry and
  30.  * every 500ms through the pr_slowtimo for timer based actions.
  31.  * The system will call the pr_drain entry if it is low on space and
  32.  * this should throw away any non-critical data.
  33.  *
  34.  * Protocols pass data between themselves as chains of mbufs using
  35.  * the pr_input and pr_output hooks.  Pr_input passes data up (towards
  36.  * UNIX) and pr_output passes it down (towards the imps); control
  37.  * information passes up and down on pr_ctlinput and pr_ctloutput.
  38.  * The protocol is responsible for the space occupied by any the
  39.  * arguments to these entries and must dispose it.
  40.  *
  41.  * The userreq routine interfaces protocols to the system and is
  42.  * described below.
  43.  */
  44. struct protosw {
  45.     short    pr_type;        /* socket type used for */
  46.     struct    domain *pr_domain;    /* domain protocol a member of */
  47.     short    pr_protocol;        /* protocol number */
  48.     short    pr_flags;        /* see below */
  49. /* protocol-protocol hooks */
  50.     /* input to protocol (from below) */
  51.     void    (*pr_input)(struct mbuf *, struct ifnet *);
  52.     /* output to protocol (from above) */
  53.     int    (*pr_output)(struct mbuf *, struct socket *);
  54.      /* control input (from below) */
  55.     void    (*pr_ctlinput)(int, struct sockaddr *);
  56.      /* control output (from above) */
  57.     int    (*pr_ctloutput)(int, struct socket *, int, int, struct mbuf **);
  58. /* user-protocol hook */
  59.      /* user request: see list below */
  60.     int    (*pr_usrreq)(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *);
  61. /* utility hooks */
  62.     void    (*pr_init)(void);       /* initialization hook */
  63.     void    (*pr_fasttimo)(void);   /* fast timeout (200ms) */
  64.     void    (*pr_slowtimo)(void);   /* slow timeout (500ms) */
  65.     void    (*pr_drain)(void);      /* flush any excess space possible */
  66. };
  67.  
  68. #define PR_SLOWHZ    2        /* 2 slow timeouts per second */
  69. #define PR_FASTHZ    5        /* 5 fast timeouts per second */
  70.  
  71. /*
  72.  * Values for pr_flags
  73.  */
  74. #define PR_ATOMIC    0x01        /* exchange atomic messages only */
  75. #define PR_ADDR     0x02        /* addresses given with messages */
  76. /* in the current implementation, PR_ADDR needs PR_ATOMIC to work */
  77. #define PR_CONNREQUIRED 0x04        /* connection required by protocol */
  78. #define PR_WANTRCVD    0x08        /* want PRU_RCVD calls */
  79. #define PR_RIGHTS    0x10        /* passes capabilities */
  80.  
  81. /*
  82.  * The arguments to usrreq are:
  83.  *    (*protosw[].pr_usrreq)(up, req, m, nam, opt);
  84.  * where up is a (struct socket *), req is one of these requests,
  85.  * m is a optional mbuf chain containing a message,
  86.  * nam is an optional mbuf chain containing an address,
  87.  * and opt is a pointer to a socketopt structure or nil.
  88.  * The protocol is responsible for disposal of the mbuf chain m,
  89.  * the caller is responsible for any space held by nam and opt.
  90.  * A non-zero return from usrreq gives an
  91.  * UNIX error number which should be passed to higher level software.
  92.  */
  93. #define PRU_ATTACH        0    /* attach protocol to up */
  94. #define PRU_DETACH        1    /* detach protocol from up */
  95. #define PRU_BIND        2    /* bind socket to address */
  96. #define PRU_LISTEN        3    /* listen for connection */
  97. #define PRU_CONNECT        4    /* establish connection to peer */
  98. #define PRU_ACCEPT        5    /* accept connection from peer */
  99. #define PRU_DISCONNECT        6    /* disconnect from peer */
  100. #define PRU_SHUTDOWN        7    /* won't send any more data */
  101. #define PRU_RCVD        8    /* have taken data; more room now */
  102. #define PRU_SEND        9    /* send this data */
  103. #define PRU_ABORT        10    /* abort (fast DISCONNECT, DETATCH) */
  104. #define PRU_CONTROL        11    /* control operations on protocol */
  105. #define PRU_SENSE        12    /* return status into m */
  106. #define PRU_RCVOOB        13    /* retrieve out of band data */
  107. #define PRU_SENDOOB        14    /* send out of band data */
  108. #define PRU_SOCKADDR        15    /* fetch socket's address */
  109. #define PRU_PEERADDR        16    /* fetch peer's address */
  110. #define PRU_CONNECT2        17    /* connect two sockets */
  111. /* begin for protocols internal use */
  112. #define PRU_FASTTIMO        18    /* 200ms timeout */
  113. #define PRU_SLOWTIMO        19    /* 500ms timeout */
  114. #define PRU_PROTORCV        20    /* receive from below */
  115. #define PRU_PROTOSEND        21    /* send to below */
  116.  
  117. #define PRU_NREQ        21
  118.  
  119. #ifdef PRUREQUESTS
  120. char *prurequests[] = {
  121.     "ATTACH",       "DETACH",       "BIND",         "LISTEN",
  122.     "CONNECT",      "ACCEPT",       "DISCONNECT",   "SHUTDOWN",
  123.     "RCVD",         "SEND",         "ABORT",        "CONTROL",
  124.     "SENSE",        "RCVOOB",       "SENDOOB",      "SOCKADDR",
  125.     "PEERADDR",     "CONNECT2",     "FASTTIMO",     "SLOWTIMO",
  126.     "PROTORCV",     "PROTOSEND",
  127. };
  128. #endif
  129.  
  130. /*
  131.  * The arguments to the ctlinput routine are
  132.  *    (*protosw[].pr_ctlinput)(cmd, arg);
  133.  * where cmd is one of the commands below, and arg is
  134.  * an optional argument (caddr_t).
  135.  *
  136.  * N.B. The IMP code, in particular, pressumes the values
  137.  *    of some of the commands; change with extreme care.
  138.  * TODO:
  139.  *    spread out codes so new ICMP codes can be
  140.  *    accomodated more easily
  141.  */
  142. #define PRC_IFDOWN        0    /* interface transition */
  143. #define PRC_ROUTEDEAD        1    /* select new route if possible */
  144. #define PRC_QUENCH        4    /* some said to slow down */
  145. #define PRC_MSGSIZE        5    /* message size forced drop */
  146. #define PRC_HOSTDEAD        6    /* normally from IMP */
  147. #define PRC_HOSTUNREACH     7    /* ditto */
  148. #define PRC_UNREACH_NET     8    /* no route to network */
  149. #define PRC_UNREACH_HOST    9    /* no route to host */
  150. #define PRC_UNREACH_PROTOCOL    10    /* dst says bad protocol */
  151. #define PRC_UNREACH_PORT    11    /* bad port # */
  152. #define PRC_UNREACH_NEEDFRAG    12    /* IP_DF caused drop */
  153. #define PRC_UNREACH_SRCFAIL    13    /* source route failed */
  154. #define PRC_REDIRECT_NET    14    /* net routing redirect */
  155. #define PRC_REDIRECT_HOST    15    /* host routing redirect */
  156. #define PRC_REDIRECT_TOSNET    16    /* redirect for type of service & net */
  157. #define PRC_REDIRECT_TOSHOST    17    /* redirect for tos & host */
  158. #define PRC_TIMXCEED_INTRANS    18    /* packet lifetime expired in transit */
  159. #define PRC_TIMXCEED_REASS    19    /* lifetime expired on reass q */
  160. #define PRC_PARAMPROB        20    /* header incorrect */
  161.  
  162. #define PRC_NCMDS        21
  163.  
  164. #ifdef PRCREQUESTS
  165. char    *prcrequests[] = {
  166.     "IFDOWN", "ROUTEDEAD", "#2", "#3",
  167.     "QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH",
  168.     "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
  169.     "FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
  170.     "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
  171.     "PARAMPROB"
  172. };
  173. #endif
  174.  
  175. /*
  176.  * The arguments to ctloutput are:
  177.  *    (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
  178.  * req is one of the actions listed below, so is a (struct socket *),
  179.  * level is an indication of which protocol layer the option is intended.
  180.  * optname is a protocol dependent socket option request,
  181.  * optval is a pointer to a mbuf-chain pointer, for value-return results.
  182.  * The protocol is responsible for disposal of the mbuf chain *optval
  183.  * if supplied,
  184.  * the caller is responsible for any space held by *optval, when returned.
  185.  * A non-zero return from usrreq gives an
  186.  * UNIX error number which should be passed to higher level software.
  187.  */
  188. #define PRCO_GETOPT    0
  189. #define PRCO_SETOPT    1
  190.  
  191. #define PRCO_NCMDS    2
  192.  
  193. #ifdef PRCOREQUESTS
  194. char    *prcorequests[] = {
  195.     "GETOPT", "SETOPT",
  196. };
  197. #endif
  198.  
  199. #ifdef KERNEL
  200. #if 0
  201. extern  struct protosw *pffindproto(), *pffindtype();
  202. #endif
  203. #endif
  204.  
  205. #endif
  206.